<template>
  <div class="app-container">
    <el-form :inline="true" ref="ruleForm" :model="formInline" class="demo-form-inline" @keyup.enter.native="search">
      <el-form-item label="等级调整时间" prop="time">
        <el-date-picker
          v-model="formInline.time"
          type="datetimerange"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd HH:mm:ss"
          :default-time="['00:00:00', '23:59:59']"
          :picker-options="pickerWeekStep">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="账户名" prop="username">
        <el-input v-model="formInline.username" placeholder="请输入账号名"></el-input>
      </el-form-item>
      <el-form-item label="等级调整前" prop="vipLevelBefore">
        <el-select v-model="formInline.vipLevelBefore" placeholder="请选择调整前等级">
          <el-option
            v-for="item in vipManage.VIP_LEVEL"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="等级调整后" prop="vipLevelAfter">
        <el-select v-model="formInline.vipLevelAfter" placeholder="请选择调整后等级">
          <el-option
            v-for="item in vipManage.VIP_LEVEL"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="调整方式" prop="optType">
        <el-select v-model="formInline.optType" placeholder="请选择调整方式">
          <el-option
            v-for="item in vipManage.OPT_TYPE_LIST"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="操作人" prop="operator">
        <el-input v-model="formInline.operator" placeholder="请输入操作人"></el-input>
      </el-form-item>
      <el-button class="filter-item" type="primary" icon="el-icon-search" @click="search">搜索</el-button>
      <el-button @click="selfResetForm('ruleForm')">重置</el-button>
      <el-button v-if="roleCheck('level-record-export')" type="primary" icon="el-icon-download" @click="clickExport" :loading="downLoading">导出</el-button>
    </el-form>
  </div>
</template>

<script>
import { form, pickerOption } from '@/build';

export default {
  name: 'form-filter',
  mixins: [form, pickerOption],
  props: {
    downLoading: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      formInline: {
        time: [
          moment().format('YYYY-MM-DD 00:00:00'),
          moment().format('YYYY-MM-DD 23:59:59'),
        ],
        username: undefined,
        vipLevelBefore: undefined,
        vipLevelAfter: undefined,
        optType: undefined,
        operator: undefined,
        size: 20,
        page: 1,
      },
    };
  },
  methods: {
    clickExport() {
      this.$emit('on-export', this.formInline);
    },
    search() {
      this.$emit('on-filter', this.formInline);
    },
    selfResetForm(formName) {
      this.resetForm(formName);
    },
  },
};
</script>

<style lang="scss" scoped>

</style>
